<%--****************************************************************************
* 文件名：moban.jsp
* 功能： 模板样式
* 版权所有：J126
* 公司名: J126
*
* --时间--               ---作者--- ----------描述----------
* 2016年10月28日 上午9:19:40         杨文晶		                   新建
*****************************************************************************--%>

<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>租户续约</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
 <link rel="styleSheet" href="../../css/bootstrap.min.css"> 
<script type="text/javascript" src="../../js/jquery-3.1.0.min.js" charset="UTF-8"></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen"> 
    <link href="../../css/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
    <link href="css/style.css" rel="stylesheet" media="screen">
<style type="text/css">
	#tablediv{
	width: 900px;
	}
	#address{
	width: 390px;
	}
	#tablediv{
	width: 900px;
	}
	#table_topDiv{
	height: 50px;
	}
	#table_bottomDiv{
	margin-top:-20px;
	height: 100px;
	margin-bottom: 20px;
	}
	
</style>
<!--杨文晶  2016年10月28日 上午9:19:40  css文件导入  end  -->
</head>
<body>
<div class="container">
<!--杨文晶 2016年10月28日 上午9:19:40  注释  start  -->
<br>
	<br>
		<label>原合同编号：</label>
		&nbsp;&nbsp;&nbsp;
		<input type="text" name="cbdNo" id="cbdNo" placeholder="原合同编号">		&nbsp;&nbsp;
		<input class="btn btn-primary" type="button" value="查询" onclick="search()">
		
		<br>
		<div id="tablediv">
		<div id="table_topDiv">
			<table class="table table-striped table-bordered ta2le-condensed">
				<thead>
					<tr>
			<th style="width:164px;">合同编号</th>
			<th style="width:132px;">合同单位</th>
			<th style="width:133px;">对方联系人</th>
			<th>对方联系电话</th>
			<th>车位所在单位详细地址</th>
			<th style="width:203px;">车位编号</th>
					</tr>
				</thead>
			</table>
			</div>
			<div id="table_bottomDiv" style="overflow-y: scroll;">
				<table  class="table table-striped table-bordered table-condensed">
					<tbody id="tableContent">
			
					</tbody>
				</table>
			</div>		
		</div>
<form action="addCompanyPact.do" class="form-horizontal" method="post" id="cbdpactFrom" onsubmit="return checkForm()"  >
	<input type="hidden" name="carportID" id="carportID"/>
	<div class="left_div">
		<div class="form-group">
   	 		<label for="pactNO" class="col-sm-4 control-label">新合同编号</label>
    		<div class="col-xs-6">
      			<input style="margin-left:-15px;" type="text" class="form-control" id="pactNO" name="pactNO" placeholder="合同编号" readonly="readonly">
    		</div>
    	</div>
    	<div class="form-group">
               <label for="dtp_input2" class="col-sm-4 control-label">合同开始时间</label>
               <div class="input-group date form_datetime col-xs-6" data-date="" data-date-format="yyyy-mm-dd hh:ii" data-link-field="pactStartTime" data-link-format="yyyy-mm-dd hh:ii">
                    <input class="form-control" type="text"  value="" readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
                </div>
				<input type="hidden"  id="pactStartTime" name="pactStartTime" value="" /><br/>
         </div>
          <div class="form-group">
              <label for="dtp_input2" class="col-sm-4 control-label">合同截止时间</label>
               <div class="input-group date pactEndTime col-xs-6" data-date="" data-date-format="yyyy-mm-dd hh:ii" data-link-field="pactEndTime" data-link-format="yyyy-mm-dd hh:ii">
                   <input class="form-control" type="text" id="showEndTime" value=""  readonly>
                    <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
					<span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
               </div>
				<input type="hidden" id="pactEndTime" name="pactEndTime" value=""  /><br/>
           </div>
 
	</div>
	<div class="right_div">
	<div class="form-group">
   	 		<label for="companyName" class="col-sm-4 control-label">合同单位</label>
   	 		<input type="hidden" name="comp.companyID" id="companyID"/>
    		<div class="col-xs-6">
				<input type="text" class="form-control"  placeholder="合同单位" name="comp.companyName" id="companyName"readonly="readonly">
    		</div>
  			</div>
  	<div class="form-group">
   	 		<label for="companyBoss" class="col-sm-4 control-label">对方联系人</label>
    		<div class="col-xs-6">
      			<input type="text" class="form-control" id="companyBoss" name="comp。companyBoss"  readonly="readonly" placeholder="对方联系人">
    		</div>
  		</div>
	
  	<div class="form-group">
   	 	<label for="companyTel" class="col-sm-4 control-label">对方联系人电话</label>
    	<div class="col-xs-6">
      	<input type="text" class="form-control" id="companyTel" name="comp。companyTel"  readonly="readonly" placeholder="对方人联系电话">
    	</div>
  </div>
	
	<div class="form-group">
   	 	<label for="companyTel" class="col-sm-4 control-label">车位所在单位详细地址</label>
    	<div class="col-xs-6">
      	<input type="text" class="form-control" id="companyAddress" name="comp。companyAddress" readonly="readonly" placeholder="车位所属单位详细地址">
    	</div>
  </div>
		
	</div>
	
		
        <div class="btn_div">
           <input style="margin-top:-40px;" type="submit" class="btn btn-info" name="submit" value="合同新增确定" />

	</div>


</form>
</div>
<!--杨文晶 2016年10月28日 上午9:19:40  end  -->

<script type="text/javascript" src="jquery/jquery-1.8.3.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="../../js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

</body>
<script type="text/javascript">
$(function(){
	$.ajax({
		url:"initPactNo.do",
		type:"post",
		data:{param:"租字"},
		success:function(msg){
			$("#pactNO").val(msg);
		}
	})
})
$('.form_datetime').datetimepicker({
    language:  'zh-CN',
    weekStart: 1,
    todayBtn:  1,
	autoclose: 1,
	todayHighlight: 1,
	startView: 2,
	forceParse: 0,
    showMeridian: 1
});
$('.pactEndTime').datetimepicker({
    language:  'zh-CN',
    weekStart: 1,
    todayBtn:  1,
	autoclose: 1,
	todayHighlight: 1,
	startView: 2, 
	forceParse: 0,
    showMeridian: 1
});
function search(){
	var pactNo = $("#cbdNo").val();
	$.ajax({
		type:"post",
		url:"findAllCompanyPactByPactNo.do",
		data:{"cbdNo":pactNo},
		async:false,
		success:function(msg){
			var table="";
			console.info(msg);
			$.each(msg,function(i,n){
				var carportNo="";
				var carportID="";
				$.each(n.companycarport,function(j,k){
					carportID +=k.carportID+",";
					carportNo +=k.carportNO+",";
				})
				$("#carportID").val(carportID);
				table+="<tr onclick='showCompany("+n.comp.companyID+")'><td style='width:162px;'>"+n.pactNO+"</td><td style='width:132px;'>"+n.comp.companyName+"</td><td style='width:137px;'>"+n.comp.companyBoss+"</td><td style='width:102px;'>"+n.comp.companyTel+"</td><td style='width:162px;'>"+n.comp.companyAddress+"</td><td>"+carportNo+"</td></tr>";
			})
			$("#tableContent").empty();
			$("#tableContent").append(table);
			
		}
	})
}
function showCompany(id){
	$.ajax({
		url:"getCompanyByID.do",
		type:"post",
		data:{"id":id},
		async:false,
		success:function(msg){
			$("#companyBoss").val(msg.companyBoss);
			$("#companyTel").val(msg.companyTel);
			$("#companyAddress").val(msg.companyAddress);
			$("#companyID").val(msg.companyID);
			$("#companyName").val(msg.companyName);
		
		}
	})
}
function checkTime(){
	var pactEndTime = $("#pactEndTime").val();
	var pactStartTime = $("#pactStartTime").val();
	if(pactEndTime=="" || pactStartTime==""){
		alert("你还未选择合约日期");
		return false;
	}else{
		var endTime = pactEndTime.split(" ")[0].split("-");
		var startTime =	pactStartTime .split(" ")[0].split("-");
		var endDate = new Date();
		endDate.setFullYear(endTime[0],endTime[1],endTime[2]);
		var startDate = new Date();
		startDate.setFullYear(startTime[0],startTime[1],startTime[2]);
		if(endDate<startDate || endDate==startDate ){
			alert("合约日期选择错误");
			$("#showEndTime").val("");
			return false;
		}else
			return true;
	}
 	
	
}
function checkForm(){
	var flag = checkTime();
	if(!flag){
		return false;
	}else{
		return true;
	}

}
</script>
</html>